package com.yami.shop.dao;

import com.yami.shop.bean.model.UnlockRecord;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * <p>
 * 解锁记录 Mapper 接口
 * </p>
 *
 * @author chajiu
 * @since 2021-06-29
 */
public interface UnlockRecordMapper extends BaseMapper<UnlockRecord> {

    //查询是否解锁该用户
    @Select("select count(*) from ch_unlock_record where from_user_id = #{aUser} and unlocked_user_id = #{bUser} and status = 1")
    Integer unlUser(@Param("aUser") String auser,@Param("bUser") String buser);

    /*@Results(
            value = {
                    @Result(column = "unlocked_user_id",property = "user",one = @One(select = "com.yami.shop.dao.UserMapper.getUserById",fetchType = FetchType.EAGER))
            }
    )*/
    //查询所有解锁过的用户
    @Select("select * from ch_unlock_record where from_user_id = #{uid} order by unlock_time desc")
    List<UnlockRecord> fandAllNulo(String uid);

}
